package com.example.util.listener;/**
 * @author wangXiao
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @Description: redis topic监听
 * @Author wangXiao
 * @Date 2024/9/30 
 **/
@Slf4j
@Component
public class WxTestRedisMessageListener implements MessageListener {

    @Override
    public void onMessage(Message message, byte[] pattern) {
        String body = new String(message.getBody());
        String channel = new String(message.getChannel());
        if(StringUtils.isEmpty(body)){
            log.error("收到的订阅消息为空");
        }
        log.info("通道为：" + channel + "---收到订阅消息为：" + body);
    }
}
